package com.shzu.jwc.ty.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shzu.jwc.ty.bean.SystemYear;
import com.shzu.jwc.ty.bean.SystemYearExample;
import com.shzu.jwc.ty.dao.SystemYearMapper;

@Service
public class SystemYearservice {
	
	@Autowired
	SystemYearMapper mapper;
	
	public Integer getoneyearby(String date)
	{
		
		SystemYearExample example=new SystemYearExample();
		SystemYearExample.Criteria criteria=example.createCriteria();
		criteria.andSystemYearNameEqualTo(date);
		if(mapper.selectByExample(example).isEmpty()) {
			return 0;
		}
		else
			return mapper.selectByExample(example).get(0).getSystemYearId();
	}
	
	public Integer addSystemyear(String value)
	{
		SystemYear systemYear=new SystemYear();
		systemYear.setSystemYearName(value);
		mapper.insert(systemYear);
		return systemYear.getSystemYearId();
	}
	
	
	public List<SystemYear> getSystemYear()
	{
		return mapper.selectByExample(null);
	}

}
